home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 351-375 / disk_352 / treewalk / rexx / backup.ftw next >
Text File  |  1992-05-06  |  2KB  |  66 lines

  1. /*
  2.  * backup treewalk routine - gets treewalk to check the exclusions
  3.  *    list, and then copies the files that need copying.
  4.  *
  5.  *    Copyright (C) 1989, 1990  Mike Meyer
  6.  *
  7.  *    This program is distributed in the hope that it will be useful,
  8.  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
  9.  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10.  */
  11. in = arg(1) || arg(2)
  12.  
  13. /* if it passes the basic filter, then do it to it */
  14. '' getclip("daily.backup")
  15. if rc = 0 then
  16.     return copy(in, 'backup'substr(in, index(in, ':')))
  17.     
  18. /* Copy things in :lib, always and forever */
  19. if index(in, ':lib/') ~= 0 then
  20.     return copy(in, 'backup'substr(in, index(in, ':')))
  21.  
  22. return 0
  23.  
  24. /*
  25.  * copy - makes sure the directory is in place for the destination,
  26.  *    then copies infile to outfile.
  27.  */
  28. copy: procedure
  29.     parse arg infile, outfile
  30.  
  31.     address command
  32.  
  33.     /* Is the directory there? */
  34.     outdex = lastpos('/', outfile)
  35.     do while outdex > 0
  36.         outdir = substr(outfile, 1, outdex - 1)
  37.         if exists(outdir) then break
  38.         outdex = lastpos('/', outfile, outdex - 1)
  39.         end
  40.     outdex = index(outfile, '/', outdex + 1)
  41.  
  42.     do while outdex > 0
  43.         outdir = substr(outfile, 1, outdex - 1)
  44.         'makedir "'outdir'"'
  45.         outdex = index(outfile, '/', outdex + 1)
  46.         end
  47.  
  48.     'copy "'infile'" to "'outfile'"'
  49.     'compress "'outfile'"'        /* Copy to ram some day... */
  50.     return rc ~= 0
  51.  
  52. /*
  53.  * Log - log the message we've been given.
  54.  */
  55. log: procedure
  56.     parse arg message
  57.  
  58.     logfile = 'logs:backup.log'
  59.     if ~open(file, logfile, 'Append') then do
  60.         say "Can't open" logfile', exiting!'
  61.         exit
  62.         end
  63.     call writeln file, date() time() || ':' message
  64.     call close file
  65.     return
  66.